package fussbudget;

public class Address {
	String	streetNumber	= "";
	String	street			= "";
	String	city			= "";
	String	state			= "";
	String	postalCode		= "";

	public Address() {

	}

	public Address(String newAddress) {
		if (newAddress != null) {
			// TODO parse the string
		}
	}

	public String toString() {
		return streetNumber + " " + street + "\n" + city + " " + state + " " + postalCode;
	}

	public String toSQL() {
		return streetNumber + "||" + street + "||" + city + "||" + state + "||" + postalCode;
	}

	public void fromSQL(String sqlStr) {
		String[] lines = sqlStr.split("||");
		if (lines != null && lines.length > 0) {
			streetNumber = lines[0];
		}
		if (lines.length > 1) {
			street = lines[1];
		}
		if (lines.length > 2) {
			city = lines[2];
		}
		if (lines.length > 3) {
			state = lines[3];
		}
		if (lines.length > 4) {
			postalCode = lines[4];
		}
	}
}
